home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++,comp.lang.c
- Path: dd.chalmers.se!news.chalmers.se!sunic!trane.uninett.no!eunet.no!EU.net!howland.reston.ans.net!cs.utexas.edu!csc.ti.com!tilde.csc.ti.com!mksol!mccall
- From: mccall@mksol.dseg.ti.com (Fred McCall)
- Subject: Re: Here's a neat idiom for y'all...
- Message-ID: <1994Mar22.163726.18125@mksol.dseg.ti.com>
- Followup-To: comp.lang.c++,comp.lang.c
- Organization: Texas Instruments Inc
- X-Newsreader: TIN [version 1.2 PL0]
- References: <CMu245.DE3@marin.cc.ca.us> <2mb4hs$4vs@crl.crl.com> <lfw.763998847@pssparc2.oc.com> <2mdapj$9ph@crl2.crl.com> <EJH.94Mar21140731@larry.gsfc.nasa.gov> <2ml75l$d00@chico.staf.phil.ruu.nl>
- Date: Tue, 22 Mar 1994 16:37:26 GMT
- Lines: 29
- Xref: dd.chalmers.se comp.lang.c++:14006 comp.lang.c:12207
-
- Hendrik Jan Veenstra (hjv@phil.ruu.nl) wrote:
-
- : But, as some other have pointed out already, this usage is fairly non-standard
- : and for many (including myself) it's 'strange' to read. It just don't look
- : good...
- : What you want to do is compare ptr to NULL -- i.e. 'if ptr equal to NULL...',
- : which would be translated to C thus: "if (ptr == NULL)...". For me 'if NULL is
- : equal to ptr' is illogical, irritating, annoying, silly, ...&*$* :-)
-
- Well, some of us find the overly-verbose 'if (ptr == NULL)'
- "illogical, irritating, annoying, silly, ..." and prefer to write it
- as 'if (!ptr)'. This makes prefectly good sense if one merely
- remembers that a pointer with a nil value is a pointer which does not
- point to a legal object -- in other words, it is an 'un-pointer'.
-
- : ANd besides, any half-decent compiler will emit a warning on construct like
- : "if (a = b)", so the probelm is non-existent to begin with.
-
- I hate compilers that do this. It's one of those messages I turn off
- (because this isn't a mistake that I, personally, make -- I make other
- mistakes, instead -- and because there are a lot of times when I *am*
- doing an assignment in the conditional clause and I don't want my real
- errors obscured by a bunch of noisy warnings).
-
- --
- "Insisting on perfect safety is for people who don't have the balls to live
- in the real world." -- Mary Shafer, NASA Ames Dryden
- ------------------------------------------------------------------------------
- Fred.McCall@dseg.ti.com - I don't speak for others and they don't speak for me.
-